// orval.config.ts
import { defineConfig } from 'orval';
import { loadEnv } from 'vite';

// 加载环境变量
const env = loadEnv('development', process.cwd(), 'VITE_');
const apiBaseUrl = env.VITE_API_BASE_URL || 'http://localhost:8000';

export default defineConfig({
  petstore: {
    input: `${apiBaseUrl}/openapi.json`,
    output: {
      target: './src/api/endpoints.ts',
      schemas: './src/api/models',
      client: 'axios',
      mode: 'tags-split',
      override: {
        mutator: {
          path: './src/utils/request.ts',
          name: 'requestInstance',
        },
      },
    },
  },
});
